package com.cola.demo.Soundsystem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Grup:Soundsystem
 * @Auther:cola
 * @Data:2021/4/17-2021-04-16:43
 * @version:1.0
 */
@Component
public class CDPlayer {

    private CompactDisc cd;

    public CDPlayer(CompactDisc cd) {
        this.cd = cd;
        System.out.println("CDPlayer的有参构造函数!"+this.toString());
    }

    public CDPlayer() {
        super();
        System.out.println("CDPlayer无参构造函数"+this.toString());
    }

    public CompactDisc getCd() {
        return cd;
    }

    public void setCd(CompactDisc cd) {
        this.cd = cd;
        System.out.println("___在"+this.toString()+"注入CD");
    }

    public void play(){
        System.out.println("CDPlayer:"+this.toString());
        if (cd!=null){
            cd.play();
        }

    }
}
